﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:converters="clr-namespace:ScrumSprintMonitor.UI.Wpf.Converters;assembly=ScrumSprintMonitor.UI.Wpf"
    xmlns:ViewModels="clr-namespace:ScrumSprintMonitor.Samples.FaroTestWatcher.ViewModels">

    <converters:DateTimeValueConverter x:Key="DateTimeValueConverter"/>

    <Style x:Key="InfoLabel" TargetType="{x:Type TextBlock}">
        <Setter Property="FontSize" Value="64" />
        <Setter Property="FontWeight" Value="Light" />
        <Setter Property="VerticalAlignment" Value="Bottom" />
        <Setter Property="HorizontalAlignment" Value="Stretch" />
        <Setter Property="Foreground" Value="LightGray" />
    </Style>

    <DataTemplate x:Key="TestsFailed">
        <StackPanel Orientation="Horizontal">
            <TextBlock Text="{Binding NumberOfTestsFailed}" Style="{StaticResource InfoLabel}" Foreground="White" />
            <TextBlock Text=" out of " Style="{StaticResource InfoLabel}" />
            <TextBlock Text="{Binding NumberOfTestsRun}" Style="{StaticResource InfoLabel}" Foreground="White" />
            <TextBlock Text=" tests failed in " Style="{StaticResource InfoLabel}" />
            <TextBlock Text="{Binding BuildNumber}" Style="{StaticResource InfoLabel}" Foreground="White" />
        </StackPanel>
    </DataTemplate>


    <DataTemplate x:Key="TestsPassed">
        <StackPanel Orientation="Horizontal">
            <TextBlock Text="All " Style="{StaticResource InfoLabel}" />
            <TextBlock Text="{Binding NumberOfTestsRun}" Style="{StaticResource InfoLabel}" Foreground="White" />
            <TextBlock Text=" tests passed in " Style="{StaticResource InfoLabel}" />
            <TextBlock Text="{Binding BuildNumber}" Style="{StaticResource InfoLabel}" Foreground="White" />
        </StackPanel>
    </DataTemplate>
    
    <DataTemplate DataType="{x:Type ViewModels:TestWatcherViewModel}">
        <Border>
            <Border.Style>
                <Style TargetType="{x:Type Border}">
                    <Setter Property="Visibility" Value="Visible" />

                    <Style.Triggers>
                        <DataTrigger Binding="{Binding Path=ShowWarning}" Value="False">
                            <Setter Property="Visibility" Value="Collapsed" />
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </Border.Style>
            <Border.OpacityMask>
                <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                    <GradientStop Offset="0.5" Color="#FFFFFFFF"/>
                    <GradientStop Offset="1.0" Color="#3FFFFFFF"/>
                </LinearGradientBrush>
            </Border.OpacityMask>

            <Grid>
                <Border CornerRadius="10" Background="{Binding BackgroundBrush}">
                    <Border.Effect>
                        <BlurEffect Radius="18" RenderingBias="Quality"/>
                    </Border.Effect>
                </Border>
                
                <Grid Margin="40,10">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="10*"/>
                        <ColumnDefinition Width="60*"/>
                        <ColumnDefinition Width="10*"/>
                        <ColumnDefinition Width="10*"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>

                    <Viewbox Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2">
                        <ContentPresenter Content="{Binding}">
                            <ContentPresenter.Style>
                                <Style TargetType="{x:Type ContentPresenter}">
                                    <Setter Property="ContentTemplate" Value="{StaticResource TestsFailed}"/>
                                    
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding NumberOfTestsFailed}" Value="0">
                                            <Setter Property="ContentTemplate" Value="{StaticResource TestsPassed}"/>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </ContentPresenter.Style>
                        </ContentPresenter>
                    </Viewbox>

                    <Viewbox Grid.Column="2" Grid.Row="1">
                        <TextBlock Text="{Binding BuildTimeStamp, StringFormat='at {0}', Converter={StaticResource DateTimeValueConverter}, ConverterParameter=G}" HorizontalAlignment="Right" FontSize="28" />
                    </Viewbox>
                </Grid>
            </Grid>
        </Border>
    </DataTemplate>
</ResourceDictionary>